using System;
using System.Collections.Generic;
using System.Text;
using BuildingBasicDomain;
using CommonTypes;
namespace BuildingStructuralElements
{
    public struct MaterialDefinitions
    {
        // public bool Initialized;

        // -- For Steel: ----------------------------------

        // Value for this is also dependent on the nominal thickness t, 
        // depending on section chosen, so it is evaluated when needed, and thus
        // no value for it is stored here.
        public String SectionSteelGrade;

        // -- Material coefficients for steel: --

        // Modulus of elasticity E
        public double SteelE;

        // Coefficient of linear thermal expansion
        public double SteelalphaT;
        // Density
        public double Steelrho;
        // Poissons ratio
        public double Steelni;

        /// <summary>
        /// Calculates and returns Shear modulus SteelG
        /// </summary>
        /// <returns></returns>
        public double GetSteelG()
        {
            // return SteelG;
            return SteelE / 2.0 / (1.0 + Steelni);
        }

        // -- For Concrete: -------------------------------

        // -- Concrete reinforcing steel grade: --

        // Reinforcing steel grades
        public String ConcreteReinforcingSteelGrade;
        // Reinforcing steel fsk
        public double ConcreteReinforcingSteelGradefsk;

        // -- Connector steel grade: --

        // Connector steel grades
        public String ConnectorSteelGrade;
        // Connector steel fsk (???)
        public double ConnectorSteelGradefsk;

        // -- Concrete steel sheeting steel grade: --

        // Yield strength of basic material for steel sheeting Grade
        public String ConcreteSteelSheetingSteelGrade;
        // Yield strength of basic material for steel sheeting fyb
        public double ConcreteSteelSheetingSteelGradefyb;

        // -- Concrete strength class: --

        // Strength class
        public String ConcreteStrengthClass;
        // fctk
        public double ConcreteStrengthClassfck;
        // fctm
        public double ConcreteStrengthClassfctm;
        // fctk 0.05
        public double ConcreteStrengthClassfctk005;
        // fctk 0.95
        public double ConcreteStrengthClassfctk095;
        // Ecm
        public double ConcreteStrengthClassEcm;

        // -- Material coefficients for concrete: --

        public double Concreterhoc;		 // Density for normal weight concrete
        public double ConcretealphaTnw;  // Coefficient of linear thermal expansion for normal weight concrete
        public double ConcretealphaTlw;	 // Coefficient of linear thermal expansion for light concrete
        public double ConcreteElasticVc; // Poissons ratio, in general for elastic strains
        public double ConcreteCrackedVc; // Poissons ratio for concrete in tension assumed to be cracked

        // Constructor
        public MaterialDefinitions
            (String iSectionSteelGrade,

            double iSteelE, double iSteelG, double iSteelalphaT, double iSteelrho, double iSteelni,

            String iConcreteReinforcingSteelGrade, double iConcreteReinforcingSteelGradefsk,

            String iConnectorSteelGrade, double iConnectorSteelGradefsk,

            String iConcreteSteelSheetingSteelGrade, double iConcreteSteelSheetingSteelGradefyb,

            String iConcreteStrengthClass, double iConcreteStrengthClassfck, double iConcreteStrengthClassfctm,
            double iConcreteStrengthClassfctk005, double iConcreteStrengthClassfctk095, double iConcreteStrengthClassEcm,

            double iConcreterhoc, double iConcretealphaTnw, double iConcretealphaTlw,
            double iConcreteElasticVc, double iConcreteCrackedVc)
        {
            SectionSteelGrade = iSectionSteelGrade;

            SteelE = iSteelE;
            SteelalphaT = iSteelalphaT;
            Steelrho = iSteelrho;
            Steelni = iSteelni;

            ConcreteReinforcingSteelGrade = iConcreteReinforcingSteelGrade;
            ConcreteReinforcingSteelGradefsk = iConcreteReinforcingSteelGradefsk;

            ConnectorSteelGrade = iConnectorSteelGrade;
            ConnectorSteelGradefsk = iConnectorSteelGradefsk;

            ConcreteSteelSheetingSteelGrade = iConcreteSteelSheetingSteelGrade;
            ConcreteSteelSheetingSteelGradefyb = iConcreteSteelSheetingSteelGradefyb;

            ConcreteStrengthClass = iConcreteStrengthClass;
            ConcreteStrengthClassfck = iConcreteStrengthClassfck;
            ConcreteStrengthClassfctm = iConcreteStrengthClassfctm;
            ConcreteStrengthClassfctk005 = iConcreteStrengthClassfctk005;
            ConcreteStrengthClassfctk095 = iConcreteStrengthClassfctk095;
            ConcreteStrengthClassEcm = iConcreteStrengthClassEcm;

            Concreterhoc = iConcreterhoc;
            ConcretealphaTnw = iConcretealphaTnw;
            ConcretealphaTlw = iConcretealphaTlw;
            ConcreteElasticVc = iConcreteElasticVc;
            ConcreteCrackedVc = iConcreteCrackedVc;
        }

        public static bool operator ==(MaterialDefinitions md1, MaterialDefinitions md2)
        {
            if (md1.SectionSteelGrade != md2.SectionSteelGrade)
                return false;
            if (md1.SteelE != md2.SteelE)
                return false;
            if (md1.SteelalphaT != md2.SteelalphaT)
                return false;
            if (md1.Steelrho != md2.Steelrho)
                return false;
            if (md1.Steelni != md2.Steelni)
                return false;

            if (md1.ConcreteReinforcingSteelGrade != md2.ConcreteReinforcingSteelGrade)
                return false;
            if (md1.ConcreteReinforcingSteelGradefsk != md2.ConcreteReinforcingSteelGradefsk)
                return false;

            if (md1.ConnectorSteelGrade != md2.ConnectorSteelGrade)
                return false;
            if (md1.ConnectorSteelGradefsk != md2.ConnectorSteelGradefsk)
                return false;

            if (md1.ConcreteSteelSheetingSteelGrade != md2.ConcreteSteelSheetingSteelGrade)
                return false;
            if (md1.ConcreteSteelSheetingSteelGradefyb != md2.ConcreteSteelSheetingSteelGradefyb)
                return false;

            if (md1.ConcreteStrengthClass != md2.ConcreteStrengthClass)
                return false;
            if (md1.ConcreteStrengthClassfck != md2.ConcreteStrengthClassfck)
                return false;
            if (md1.ConcreteStrengthClassfctm != md2.ConcreteStrengthClassfctm)
                return false;
            if (md1.ConcreteStrengthClassfctk005 != md2.ConcreteStrengthClassfctk005)
                return false;
            if (md1.ConcreteStrengthClassfctk095 != md2.ConcreteStrengthClassfctk095)
                return false;
            if (md1.ConcreteStrengthClassEcm != md2.ConcreteStrengthClassEcm)
                return false;

            if (md1.Concreterhoc != md2.Concreterhoc)
                return false;
            if (md1.ConcretealphaTnw != md2.ConcretealphaTnw)
                return false;
            if (md1.ConcretealphaTlw != md2.ConcretealphaTlw)
                return false;
            if (md1.ConcreteElasticVc != md2.ConcreteElasticVc)
                return false;
            if (md1.ConcreteCrackedVc != md2.ConcreteCrackedVc)
                return false;

            return true;
        }

        public static bool operator !=(MaterialDefinitions md1, MaterialDefinitions md2)
        {
            return !(md1 == md2);
        }

        public override bool Equals(object o)
        {
            if (this == (MaterialDefinitions)o)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
